package cn.jsp;

import cn.jsp.dao.BaseDao;
import cn.jsp.domain.Stu;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@WebServlet("/generalRowProcessor")
public class GeneralRowProcessorServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(req.getServletContext());
        BaseDao dao=ctx.getBean(BaseDao.class);
        List<Stu> res=dao.find("select * from stu",Stu.class);
        resp.getWriter().println(res);
    }
}
